home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / SLTPU70C / BACKTRAK.PAS < prev    next >
Pascal/Delphi Source File  |  1993-03-21  |  3KB  |  97 lines

  1.  
  2. Program BackTrak;
  3.  
  4. Uses Dos;
  5.  
  6.   { pops menus off the ram resident menu stack }
  7.  
  8. const MaxStack = 40;    { menu stack maximum size }
  9.       SLBBSID = $736C;  { code for interrupt identifications }
  10.       RSInt = $7E;      { modem driver interrupt }
  11.  
  12. type ExecType = (Display,Execute);
  13.      Ansitype = (GENERIC,PROCOMM,STANDARD);
  14.  
  15.      { Following is the data format in which the menu stack is stored
  16.        in memory during door execution. With care, door programs can
  17.        modify this data area in order to produce changes in menu
  18.        execution when control returns from the door to Searchlight. }
  19.  
  20.      MenuData = Record
  21.        Count: integer;          { # of active menus }
  22.        FilesCount: integer;     { menu that called files system, 0 if none }
  23.        Menus: Array[1..MaxStack] of record
  24.          Name: string[8];       { menu filename }
  25.          Pos: integer;          { cursor position within menu }
  26.          Mode: ExecType;        { display/execute }
  27.        end;
  28.      end;
  29.  
  30. Type SlDataType = record   { public area; contains menu stack }
  31.       PROGID: string[6];                { Program ID }
  32.       carrier: boolean;                 { carrier check enable }
  33.       writeprotect: boolean;            { disk write protection }
  34.       aborttype: byte;                  { 0=no abort, 1=terminate, 2=reboot }
  35.       rsactive: boolean;                { set if rs232 active }
  36.       ansi: boolean;                    { user ANSI mode }
  37.       color: boolean;                   { user COLOR mode }
  38.       directvid: boolean;               { system DirectVid mode }
  39.       curratt: byte;                    { current video attribute }
  40.       commtype: byte;                   { run parameter }
  41.       idletime: word;                   { idle limit (seconds) }
  42.       lastkey: boolean;                 { TRUE = last key from local kbd }
  43.       OldVector: array[$00..$7F] of pointer;   { old user int vectors }
  44.       AnsiMode: AnsiType;               { caller's ansi mode }
  45.       SLMenuStack: MenuData;            { active menu stack }
  46.     end;
  47.  
  48. var MenuStack: ^MenuData;
  49.     n,i: integer;
  50.  
  51.  
  52. Procedure InitStack;
  53. var SLData: ^SLDataType;
  54.     p: pointer;
  55.     regs: registers;
  56. Begin
  57.   SLData:=Nil;
  58.   GetIntVec($79,p);
  59.   if longint(p)=SLBBSID then begin        { check SL installation }
  60.     regs.ax:=$C7;
  61.     regs.cx:=$00;
  62.     Intr(RSInt,regs);                     { get public data area pointer }
  63.     if (regs.cx=SLBBSID)
  64.       then SLData:=Ptr(regs.ax,regs.bx);
  65.   end;
  66.   if (SLData<>Nil)
  67.     then MenuStack:=@Sldata^.SLMenuStack
  68.     else MenuStack:=Nil;  { slbbs not loaded }
  69. end;
  70.  
  71.  
  72.  
  73. Begin
  74.   n:=1;
  75.   if ParamCount>0 then begin    { read number off command line }
  76.     Val(ParamStr(1),n,i);
  77.     if (i<>0) then n:=0;
  78.   end;
  79.  
  80.   if (n>0) then begin
  81.     InitStack;                      { point to menu stack in memory }
  82.     if (menustack<>Nil) then
  83.     with menustack^ do begin
  84.       if count>1 then begin
  85.         i:=count;
  86.         count:=count-n;
  87.         if count<1 then count:=1;   { don't back up past first menu }
  88.         if (filescount>0) and (count<=filescount)
  89.           then count:=filescount+1; { don't back out of files system }
  90.         if (count<>i) and (Menus[count].mode=Execute)
  91.           then inc(Menus[count].pos);  { inc position to prevent loops }
  92.       end;
  93.     end;
  94.   end;
  95.  
  96. end.
  97.